#pragma once
#include "stdafx.h"
#include "EntityControl.h"
#include "TriggerAction.h"
#include "TriggerRequirement.h"

class EntityControl;
class TriggerAction;
class TriggerRequirement;

class _OgreMoveExport Trigger
{
	bool dirty;
	bool deleted;
	bool allReqDirty;

	std::vector<TriggerRequirement*> TriggerRequirements;
	std::vector<TriggerRequirement*> dirtyTriggerRequirements;
	std::vector<TriggerAction*> TriggerActions;

	int countOfReqs;
	int countOfAccceptedReqs;

	
public:
	Trigger(void);
	~Trigger(void);

	
	//Checks the requirements fot the trigger
	bool CheckReq(EntityControl *entity);
	//Fires the trigger, if returns with true the trigger must be deleted
	bool FireTrigger(EntityControl *entity);


	//Template method for using a trigger, returns true is the trigger must be deleted
	bool UseTrigger(EntityControl *entity);

	void addRequiement(TriggerRequirement* req);
	std::vector<TriggerRequirement*> getRequirements();

	void addAction(TriggerAction* action);

	void subscribeParameterChanged(EntityControl *entity);


	void setDirty(EntityControl *sourceEntity,TriggerRequirement *dirtyReq);
	//Set a Trigger dirty if it was satisfied but didnt deleted.
	void setDirty(EntityControl *sourceEntity);

	void setDeletedFlag(EntityControl *entity);
	bool getDeletedFlag();

	void setAllReqDirty(bool dirty);

};

